package ipmsg.file;

import java.io.File;
import java.io.IOException;















public class ConfigUtility
{
  public static final char file = '\000';
  public static final char dir = '\001';
  public static final char neither = '\002';
  
  private static char getFileKind(String path)
  {
    File fr = new File(path);
    if (fr == null) { return '\002';
    }
    if (fr.isFile())
      return '\000';
    if (fr.isDirectory()) {
      return '\001';
    }
    return '\002';
  }
  




  public static void delFile(String path)
  {
    if (getFileKind(path) != '\002') {
      new File(path).delete();
    }
  }
  



















  public static void creatFile(String path, char fileKind)
  {
    if (fileKind == '\002') return;
    if ((fileKind == '\001') && (getFileKind(path) == '\001')) { return;
    }
    delFile(path);
    try
    {
      if (fileKind == 0) {
        new File(path).createNewFile();
      }
      else if (fileKind == '\001') {
        new File(path).mkdir();
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
}
